package cn.script.app;

import cn.script.app.bean.AppInfo;
import cn.script.app.start.GameStart;
import cn.script.fxj.FXBaseController;
import javafx.collections.ObservableList;
import javafx.fxml.FXML;
import javafx.scene.control.Button;

public class AppAction extends FXBaseController {

    @FXML
    RoleAction roleController;

    @FXML
    ScriptSetAction scriptController;

    @FXML
    LogAction logController;

//    @FXML
//    LogAction logView;

    @FXML
    RunAction runController;


    AppInfo appInfo = new AppInfo();

    @Override
    public void initLoad() throws Exception {
        super.initLoad();
        this.appInfo.setmInfo(this.roleController.getmRoleInfo());
        this.appInfo.settInfo(this.roleController.gettRoleInfo());
        this.appInfo.setsInfo(this.scriptController.getScriptInfo());
        this.appInfo.setRunInfo(this.runController.getRunInfo());
    }

    @FXML
    Button okBtn;

    @FXML
    public void okAction() {
        String se = this.okBtn.getText();
        ObservableList<String> styleClass = this.okBtn.getStyleClass();
        if (se.equals("启动")) {
            if (!GameStart.start(this.appInfo)) {
                return;
            }
            this.okBtn.setText("停止");
            styleClass.remove("btn-info");
            styleClass.add("btn-danger");
        } else {
            if (!GameStart.stop()) {
                return;
            }
            this.okBtn.setText("启动");
            styleClass.remove("btn-danger");
            styleClass.add("btn-info");

        }


//        RadioButton radioButton = (RadioButton) this.scriptSetAction.getDupRadio().getSelectedToggle();
//        String text = radioButton.getText();
//        System.out.println(text);
//        Label m_id = this.roleAction.getM_id();
//        System.out.println(m_id.getText());
    }
}
